//
//  MSPopupFileView.m
//  MSPopupsManager_Example
//
//  Created by zz on 22.4.24.
//  Copyright © 2024 huizhou.wang. All rights reserved.
//

#import "MSPopupFileView.h"
#import <Masonry/Masonry.h>
#import <MSPopupsManager/MSPopupManagerConfig.h>

@interface MSPopupFileView()

@property (nonatomic, strong) UIView *imageView;

@end

@implementation MSPopupFileView


- (instancetype)init
{
    self = [super init];
    if (self) {
        self.imageView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 100, 100)];
        self.imageView.backgroundColor = [UIColor greenColor];
        [self addSubview:self.imageView];
    }
    return self;
}

- (UIView *)supportAtmospherePopupView {
    return  self;
}

- (void)layoutContentWithSuperView:(UIView *)superView {
    self.backgroundColor = [UIColor darkGrayColor];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(superView).offset(30);
        make.right.equalTo(superView).offset(-100);
        make.centerY.equalTo(superView);
        make.height.mas_equalTo(400);
    }];
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(gggg) forControlEvents:UIControlEventTouchUpInside];
    [superView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mas_top).offset(-20);
        make.right.mas_equalTo(self.mas_right).offset(-30);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
}
-(void)setHandler:(clickHandler _Nonnull)handler {
    _handler = [handler copy];
}

-(void)gggg {
    NSLog(@"--click========gggggggg");
    [MSPopupManager dismissWithPopup:self];
    if (self.handler) {
        self.handler();
    }
}

- (void)countTimeWithCount:(NSInteger)count {
    NSLog(@"=====================%ld",count);
}

- (void)dealloc {
    NSLog(@"dealloc===============MSPopupFileView");
}

@end
